package com.cluster.platform.controller;

import com.cluster.platform.common.api.CommonResult;
import com.cluster.platform.dto.CmsTagsInfoDto;
import com.cluster.platform.model.CmsTagsInfo;
import com.cluster.platform.service.CmsTagsInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: CmsTagsInfoController
 */
@Controller
@Api(tags = "标签管理接口", value = "CmsTagsInfoController")
@RequestMapping("/cmsTags")
public class CmsTagsInfoController {

    @Autowired
    private CmsTagsInfoService cmsTagsInfoService;

    // 分页查询
    @ApiOperation("标签分页查询")
    @RequestMapping(value = "/searchTags", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Object> searchTags(@RequestBody CmsTagsInfoDto cmsTagsInfoDto) {
        return cmsTagsInfoService.searchTagsPage(cmsTagsInfoDto);
    }

    // 新增
    @ApiOperation("新增标签")
    @RequestMapping(value = "/addTags", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Object> addTags(@RequestBody CmsTagsInfo cmsTagsInfo) {
        return cmsTagsInfoService.addTags(cmsTagsInfo);
    }

    // 修改
    @ApiOperation("修改标签")
    @RequestMapping(value = "/updateTags", method = RequestMethod.PUT)
    @ResponseBody
    public CommonResult<Object> updateTags(@RequestBody CmsTagsInfo cmsTagsInfo) {
        return cmsTagsInfoService.updateTags(cmsTagsInfo);
    }

    // 删除
    @ApiOperation("删除标签")
    @RequestMapping(value = "/delTags", method = RequestMethod.DELETE)
    @ResponseBody
    public CommonResult<Object> delTags(@RequestBody CmsTagsInfo cmsTagsInfo) {
        return cmsTagsInfoService.delTags(cmsTagsInfo);
    }

    // 批量操作
    @ApiOperation("批量操作")
    @RequestMapping(value = "/batchTags", method = RequestMethod.PUT)
    @ResponseBody
    public CommonResult<Object> batchTags(@RequestParam("status") Integer status, @RequestParam("ids") List<String> ids) {
        return cmsTagsInfoService.batchTags(status, ids);
    }

}
